<div class="fm-content">
  <!-- 最上面标题栏 -->
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;人员管理
  </div>
  <!-- 内容 -->
  <div class="work">

    <!-- 查询框 -->
    <div class="top">
      <nz-tree-select required class="fm-input first-input" [(ngModel)]="key" name="departmentId" nzPlaceHolder="部门"
        [nzDropdownMatchSelectWidth]="true" [nzDropdownStyle]="{ 'max-height': '300px' }" [nzAsyncData]="true"
        [nzNodes]="depDic.treeDatas">
      </nz-tree-select>
      <input nz-input placeholder="姓名" class="fm-input" [(ngModel)]="fs.queryObject['userName:like']" />
      <nz-select class="fm-input" [(ngModel)]="fs.queryObject['employeetype']" name="employeetype"
        (nzOpenChange)="userTypeDic.load('0')" [nzPlaceHolder]="'员工类型'">
        <nz-option *ngFor="let option of userTypeDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
        </nz-option>
        <nz-option *ngIf="userTypeDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading" class="loading-icon"></i>加载中...
        </nz-option>
      </nz-select>
      <nz-button-group>
        <button nz-button nzType="primary" (click)="loadData()">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="editRow(null)">新增</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
          <button nz-button (click)="fs.export('user.html','用户列表.xls')">导出</button>
        </nz-button-group>
      </div>
    </div>

    <!-- 右则样表单主体 -->
    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
            <tr>
              <th nzWidth="5%" nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)">
              </th>
              <th nzWidth="15%">姓名</th>
              <th nzWidth="20%">部门</th>
              <th nzWidth="15%">类型</th>
              <th nzWidth="30%">角色</th>
              <th nzWidth="15%">操作</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td>
                <img style="width: 40px;height: 40px;border-radius:20px"
                  *ngIf="data.uImage ? data.uImage.length === 1 : false" [src]="data.uImage[0].url" />
                <span (click)="editRow(data)" class="form-edit">
                  {{data.userName}}
                </span>
              </td>
              <td>
                {{data.departmentName}}
              </td>
              <td>
                {{data.employeetypeName}}
              </td>
              <td>
                {{data.roleNames}}
              </td>
              <td>
                <a (click)="login(data)" class="form-button">登录授权</a>
              </td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='500' nzTitle="登录授权" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="uafs.isEditVisible"
      (nzOnCancel)="uafs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">帐号</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="accounts.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [(ngModel)]="uafs.er.accounts" name="accounts" #accounts="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">密码</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="password.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [(ngModel)]="uafs.er.password" name="password" #password="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">是否有效</nz-form-label>
              <nz-form-control class="form-control">
                 <label nz-checkbox [(ngModel)]="uafs.er.valid" name="valid">有效</label>
<!--                {{uafs.er.valid | boolReform}}-->
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="uafs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary" [disabled]='accounts.invalid || password.invalid' (click)="uafs.save()"
              [nzLoading]="uafs.isSaveing">授权</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>
